// 列表头按钮配置
import {getDict} from "@/api/common";
import {getCurrentWarehouseCode} from "@/api/inbound/mesInTask";
import {getPrintTypeList} from "@/api/cabinet/cabinetPrint";

export const operateList = [
  // {
  //   name: $i18n.t("common.add"),
  //   type: "primary",
  //   icon: "el-icon-circle-plus-outline",
  //   handleName: "add", // 点击时返回的标识
  // },
  // {
  //   name: $i18n.t("common.delete"),
  //   type: "danger",
  //   icon: "el-icon-delete",
  //   handleName: "deleteBatch", // 点击时返回的标识
  //   isMultiple: true,
  // },
];
// 行末按钮配置
export const rowConfig = [
  {
    name: "查看图片",
    type: "primary",
    class: "row-btn-primary",
    handleName: "showPhoto", //点击时返回的标识
  },
];
// 搜索条件配置
export const searchConfig = {
  data() {
    const self = this;
    return {
      searchDialog: {
        inline: true,
        formDesc: {
          materialName: {
            type: "input",
            label: '物料编号/名称',
          },
          orderCode: {
            type: "input",
            label: '单据编号',
          },
          materialBrand: {
            type: "input",
            label: '物料品牌',
          },
          materialUnit: {
            type: "input",
            label: '物料规格',
          },
          vendorName: {
            type: "input",
            label: '供应商',
          },
          orderState: {
            type: "select",
            label: "物料状态",
            prop: {
              value: "value",
              text: "text",
            },
            options: [
              {
                value: "1",
                text: "询价中"
              },
              {
                value: "2",
                text: "已确认"
              },
              {
                value: "6",
                text: "部分到货"
              },
              {
                value: "3",
                text: "已到货"
              },
              {
                value: "4",
                text: "已领取"
              },
              {
                value: "5",
                text: "已取消"
              },
            ],
          },
        },
      },
    };
  },
};
// 新增/删除表单配置
export const formDescDialogMixin = {
  data() {
    const self = this;
    return {
      formDescDialog: {
        span: 24,
        formDesc: {
          repairProf: {
            type: "select",
            label: '工种',
            prop: {
              text: "description",
              value: "value"
            },
            layout: 24,
            // Promise 对象
            options: async (data) => {
              const list = await getDict("work_type")
              return list.data.result
            }
          },
          repairCateFir: {
            type: "select",
            label: '一级分类',
            prop: {
              text: "description",
              value: "value"
            },
            layout: 24,
            // Promise 对象
            options: async (data) => {
              const list = await getDict("mes_repair_item_fir")
              return list.data.result
            }
          },
          repairCateSec: {
            type: "input",
            label: '二级分类',
            layout: 24,
          },
          repairItem: {
            type: "input",
            label: '维修项目',
            layout: 24,
            required: true,
          },
          repairHours: {
            type: "number",
            label: '工时',
            layout: 24,
            attrs: {
              min: 0,
            },
            on: {
              change: (e) => {
                self.formDataDialog.repairHoursTotalPrice = Math.round(( self.formDataDialog.repairHours * self.formDataDialog.repairHoursUnitPrice)*1000)/1000;
              }
            },
          },
          repairHoursUnitPrice: {
            type: "number",
            label: '工时单价',
            layout: 24,
            attrs: {
              min: 0,
            },
            on: {
              change: (e) => {
                self.formDataDialog.repairHoursTotalPrice = Math.round(( self.formDataDialog.repairHours * self.formDataDialog.repairHoursUnitPrice)*1000)/1000;
              }
            },
          },
          repairHoursTotalPrice: {
            type: "number",
            label: '工时总价',
            layout: 24,
            attrs: {
              min: 0,
            },
          },
          isBase: {
            label: "基础整备项",
            type: "select",
            layout: 24,
            options: [
              { text: "是", value: "Y" },
              { text: "否", value: "N" }
            ]
          },
          isRepair: {
            label: "使用物料",
            type: "select",
            layout: 24,
            options: [
              { text: "是", value: "Y" },
              { text: "否", value: "N" }
            ],
          },
          repairMaterialName: {
            type: "input",
            disabled: () => {
              return self.formDataDialog.isRepair !== 'Y'
            },
            label: '使用物料名称',
            layout: 24,
          },
        },
      },
    };
  },
};
